<?php //echo $this->form->render($this);?>


<script type="text/javascript">	
//<![CDATA[
  window.addEvent('domready', function() {
  if(document.getElementById('file_7')){
  document.getElementById('file_7').addEventListener('change', handleFileSelect, false);
  }
    
	
	<?php if($this->chapter_id > 0): ?>
	$$('.layout_story_create_story_thread').show();
	<?php endif; ?>
	<?php if($this->story_id): ?>
	tabContainerSwitch($$('.tab_layout_story_create_story_thread a')[0], 'generic_layout_container layout_story_create_story_thread');
	<?php endif; ?>
  })
//]]>
</script>

<?php if($this->type == "invite"): ?>
<?php echo $this->form->render($this);?>
<?php else: ?>
<script type="text/javascript">
    //<![CDATA[
tinyMCE.init({
mode: "exact",
plugins: "emotions, table, fullscreen, preview, paste, style, layer, xhtmlxtras",
theme: "advanced",
theme_advanced_buttons1: "cut,copy,paste,pastetext,pasteword,|,undo,redo,|,link,unlink,anchor,charmap,image,media,|,justifyleft,justifycenter,justifyright,justifyfull,|,hr,removeformat,code,preview",
theme_advanced_buttons2: "bold,italic,underline,strikethrough,|,bullist,numlist,|,outdent,indent,|,tablecontrols",
theme_advanced_buttons3: "formatselect,fontselect,fontsizeselect,|,forecolor,backcolor,|,styleprops,attribs,|,blockquote,sub,sup",
theme_advanced_toolbar_align: "left",
theme_advanced_toolbar_location: "top",
element_format: "html",
height: "420",
convert_urls: "",
media_strict: false,
language: "en",
directionality: "ltr",
remove_script_host: "",
relative_urls: "",
elements: "body_7",
width: "500",
extended_valid_elements: "*[*],**,object[width|height|classid|codebase|id|name],param[name|value],embed[src|type|width|height|flashvars|wmode|id|name],iframe[src|style|width|height|scrolling|marginwidth|marginheight|frameborder|id|name|class],video[src|type|width|height|flashvars|wmode|class|poster|preload|id|name],source[src]"
});    //]]>
</script>

<style type="text/css">
.chapter_order {
	float: right;
	margin-right: 10px;
	font-weight: 700;
	margin-bottom: 10px;
}

.preview_content {
	padding: 5px !important;
	background: #EEEEEE;	
	margin-bottom: 10px;
}

.preview_content {
	max-height: 400px;
	overflow-y: auto;
}
</style>

<div class="preview_chapter">
<?php if($this->prevChapter != null): ?>
<div class="preview_content">
<h4>Preview of Previous Chapter</h4>
<?php 
echo $this->prevChapter->body;
?>
</div>
<?php endif; ?>
<div class="chapter_order">Chapter Number: <?php echo $this->chapter_number;?></div>
</div>

<form id="story_create_7" enctype="multipart/form-data" class="global_form" action="<?php echo $this->baseUrl();?>/stories/createex" onsubmit="return en4.story.handlesubmit(this);" method="post"><div><div><div class="form-elements">
<?php if(empty($this->prevChapter)): ?>
<div id="title-wrapper" class="form-wrapper">
	<div id="title-label" class="form-label">
		<label for="title" class="required">Name of Story Thread</label>
	</div>
	<div id="title-element" class="form-element">
		<input value="<?php echo $this->story->title; ?>" type="text" name="title" id="title">
	</div>
</div>
<?php endif; ?>
<div id="title-wrapper" class="form-wrapper">
	<div id="title-label" class="form-label">
		<label for="title" class="required">Name of Chapter</label>
	</div>
	<div id="title-element" class="form-element">
		<input value="<?php echo $this->lastChapter->title; ?>" type="text" name="chapter_title" id="chapter_title">
	</div>
</div>
<div id="body_7-wrapper" class="form-wrapper"><div id="body_7-label" class="form-label"><label for="body_7" class="required">Chapter Body</label></div>
<div id="body_7-element" class="form-element">
	<textarea name="body_7" id="body_7"><?php echo $this->lastChapter->body; ?></textarea>
</div>
</div>

<div id="file_7-wrapper" class="form-wrapper"><div id="file_7-label" class="form-label"><label for="file_7" class="optional">Upload Content</label></div>
<div id="file_7-element" class="form-element"><p class="description">You can upload content a txt file. Once uploaded, it will go directly to the text area of the story.</p>

<input type="file" name="file_7" id="file_7"></div></div>

<?php if(empty($this->prevChapter)): ?>
<div id="photo-wrapper" class="form-wrapper"><div id="photo-label" class="form-label"><label for="photo" class="optional">Cover Photo</label></div>
<div id="photo-element" class="form-element"><p class="description">Please upload your Cover Image for Search and Browse Story</p>

<input type="file" name="photo" id="photo"></div></div>
<?php endif; ?>
<div id="agree-wrapper" class="form-wrapper"><div class="form-label" id="agree-label">&nbsp;</div>
<div id="agree-element" class="form-element">
<input type="hidden" name="agree" value=""><input type="checkbox" name="agree" id="agree" value="1" checked="checked">
<label for="agree" class="optional">I accept the term and privacy of story creation</label></div></div>
<div id="buttons-wrapper" class="form-wrapper"><div id="buttons-label" class="form-label">&nbsp;</div><div id="buttons-element" class="form-element"><div class="form-wrapper" id="buttons-wrapper"><fieldset id="fieldset-buttons">

<?php if($this->chapter_number > 1): ?>
<button name="save" id="save" type="submit">Save</button>
<?php endif; ?>

<button name="publish" id="submit" type="submit">Begin New Chapter</button>
<?php if($this->chapter_number >= 3 && $this->is_owner && $this->story->published==0): ?>
<button name="publish" id="publish" type="submit">Publish</button>

<?php endif; ?>

 or <a name="cancel" id="cancel" type="button" href="javascript:void(0);" onclick="history.go(-1); return false;">cancel</a></fieldset></div></div></div>

<input type="hidden" name="category_id" value="7" id="category_id">
<input type="hidden" name="tags" value="" id="tags">
<input type="hidden" name="story_id" value="<?php echo $this->story_id; ?>" id="story_id">
<input type="hidden" name="auth_view" value="" id="auth_view">
<input type="hidden" name="auth_comment" value="" id="auth_comment">
<input type="hidden" name="story_category" value="" id="story_category">
</div>
</div>
</div>
</form>

<?php endif; ?>

